/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'central';
  
  checkConfig(config);
  @endpoint = getEndpoint('yundun-dbaudit', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ConfigInstanceNetworkRequest {
  instanceId?: string(name='InstanceId'),
  privateWhiteList?: [ string ](name='PrivateWhiteList'),
  publicAccessControl?: int32(name='PublicAccessControl'),
  publicWhiteList?: [ string ](name='PublicWhiteList'),
  regionId?: string(name='RegionId'),
  securityGroupIds?: [ string ](name='SecurityGroupIds'),
}

model ConfigInstanceNetworkResponseBody = {
  requestId?: string(name='RequestId'),
}

model ConfigInstanceNetworkResponse = {
  headers: map[string]string(name='headers'),
  body: ConfigInstanceNetworkResponseBody(name='body'),
}

async function configInstanceNetworkWithOptions(request: ConfigInstanceNetworkRequest, runtime: Util.RuntimeOptions): ConfigInstanceNetworkResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.privateWhiteList)) {
    query['PrivateWhiteList'] = request.privateWhiteList;
  }
  if (!Util.isUnset(request.publicAccessControl)) {
    query['PublicAccessControl'] = request.publicAccessControl;
  }
  if (!Util.isUnset(request.publicWhiteList)) {
    query['PublicWhiteList'] = request.publicWhiteList;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.securityGroupIds)) {
    query['SecurityGroupIds'] = request.securityGroupIds;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConfigInstanceNetwork',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function configInstanceNetwork(request: ConfigInstanceNetworkRequest): ConfigInstanceNetworkResponse {
  var runtime = new Util.RuntimeOptions{};
  return configInstanceNetworkWithOptions(request, runtime);
}

model DescribeInstanceAttributeRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model DescribeInstanceAttributeResponseBody = {
  instanceAttribute?: {
    accessType?: int32(name='AccessType'),
    description?: string(name='Description'),
    ecsStatus?: string(name='EcsStatus'),
    expireTime?: long(name='ExpireTime'),
    imageVersionName?: string(name='ImageVersionName'),
    instanceId?: string(name='InstanceId'),
    instanceStatus?: string(name='InstanceStatus'),
    internetEndpoint?: string(name='InternetEndpoint'),
    internetIp?: string(name='InternetIp'),
    intranetEndpoint?: string(name='IntranetEndpoint'),
    intranetIp?: string(name='IntranetIp'),
    licenseCode?: string(name='LicenseCode'),
    networkType?: string(name='NetworkType'),
    operatable?: boolean(name='Operatable'),
    planUpgradeStatus?: int32(name='PlanUpgradeStatus'),
    planUpgradeable?: boolean(name='PlanUpgradeable'),
    privateWhiteList?: [ string ](name='PrivateWhiteList'),
    publicAccessControl?: int32(name='PublicAccessControl'),
    publicWhiteList?: [ string ](name='PublicWhiteList'),
    regionId?: string(name='RegionId'),
    renewable?: boolean(name='Renewable'),
    securityGroupIds?: [ string ](name='SecurityGroupIds'),
    seriesCode?: string(name='SeriesCode'),
    startTime?: long(name='StartTime'),
    upgradeStatus?: int32(name='UpgradeStatus'),
    upgradeable?: boolean(name='Upgradeable'),
    vpcId?: string(name='VpcId'),
    vswitchId?: string(name='VswitchId'),
  }(name='InstanceAttribute'),
  requestId?: string(name='RequestId'),
}

model DescribeInstanceAttributeResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeInstanceAttributeResponseBody(name='body'),
}

async function describeInstanceAttributeWithOptions(request: DescribeInstanceAttributeRequest, runtime: Util.RuntimeOptions): DescribeInstanceAttributeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeInstanceAttribute',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeInstanceAttribute(request: DescribeInstanceAttributeRequest): DescribeInstanceAttributeResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeInstanceAttributeWithOptions(request, runtime);
}

model DescribeInstancesRequest {
  currentPage?: int32(name='CurrentPage'),
  instanceId?: [ string ](name='InstanceId'),
  instanceStatus?: string(name='InstanceStatus'),
  pageNo?: int32(name='PageNo'),
  pageSize?: int32(name='PageSize'),
  regionId?: string(name='RegionId'),
  resourceGroupId?: string(name='ResourceGroupId'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model DescribeInstancesResponseBody = {
  instances?: [ 
    {
      description?: string(name='Description'),
      ecsStatus?: string(name='EcsStatus'),
      expireTime?: long(name='ExpireTime'),
      imageVersionName?: string(name='ImageVersionName'),
      instanceId?: string(name='InstanceId'),
      instanceStatus?: string(name='InstanceStatus'),
      internetEndpoint?: string(name='InternetEndpoint'),
      internetIp?: string(name='InternetIp'),
      intranetEndpoint?: string(name='IntranetEndpoint'),
      intranetIp?: string(name='IntranetIp'),
      legacy?: boolean(name='Legacy'),
      licenseCode?: string(name='LicenseCode'),
      networkType?: string(name='NetworkType'),
      operatable?: boolean(name='Operatable'),
      planUpgradeStatus?: int32(name='PlanUpgradeStatus'),
      planUpgradeable?: boolean(name='PlanUpgradeable'),
      regionId?: string(name='RegionId'),
      renewable?: boolean(name='Renewable'),
      seriesCode?: string(name='SeriesCode'),
      startTime?: long(name='StartTime'),
      upgradeStatus?: int32(name='UpgradeStatus'),
      upgradeable?: boolean(name='Upgradeable'),
      vpcId?: string(name='VpcId'),
      vswitchId?: string(name='VswitchId'),
    }
  ](name='Instances'),
  requestId?: string(name='RequestId'),
  totalCount?: long(name='TotalCount'),
}

model DescribeInstancesResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeInstancesResponseBody(name='body'),
}

async function describeInstancesWithOptions(request: DescribeInstancesRequest, runtime: Util.RuntimeOptions): DescribeInstancesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.instanceStatus)) {
    query['InstanceStatus'] = request.instanceStatus;
  }
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeInstances',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeInstances(request: DescribeInstancesRequest): DescribeInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeInstancesWithOptions(request, runtime);
}

model DescribeLoginTicketRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model DescribeLoginTicketResponseBody = {
  loginTicket?: {
    certificate?: string(name='Certificate'),
    ticket?: string(name='Ticket'),
    zones?: [ 
      {
        localName?: string(name='LocalName'),
        zoneId?: string(name='ZoneId'),
      }
    ](name='Zones'),
  }(name='LoginTicket'),
  requestId?: string(name='RequestId'),
}

model DescribeLoginTicketResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeLoginTicketResponseBody(name='body'),
}

async function describeLoginTicketWithOptions(request: DescribeLoginTicketRequest, runtime: Util.RuntimeOptions): DescribeLoginTicketResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeLoginTicket',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeLoginTicket(request: DescribeLoginTicketRequest): DescribeLoginTicketResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeLoginTicketWithOptions(request, runtime);
}

model DescribeRegionsRequest {
  acceptLanguage?: string(name='AcceptLanguage'),
  regionId?: string(name='RegionId'),
}

model DescribeRegionsResponseBody = {
  regions?: [ 
    {
      localName?: string(name='LocalName'),
      regionEndpoint?: string(name='RegionEndpoint'),
      regionId?: string(name='RegionId'),
    }
  ](name='Regions'),
  requestId?: string(name='RequestId'),
}

model DescribeRegionsResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeRegionsResponseBody(name='body'),
}

async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.acceptLanguage)) {
    query['AcceptLanguage'] = request.acceptLanguage;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeRegions',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model DescribeSyncInfoRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model DescribeSyncInfoResponseBody = {
  instanceInfo?: {
    accessType?: int32(name='AccessType'),
    aliuid?: long(name='Aliuid'),
    customName?: string(name='CustomName'),
    ecsEip?: string(name='EcsEip'),
    ecsInstanceId?: string(name='EcsInstanceId'),
    ecsInternetIp?: string(name='EcsInternetIp'),
    ecsIntranetIp?: string(name='EcsIntranetIp'),
    ecsNetworkType?: string(name='EcsNetworkType'),
    ecsStatus?: string(name='EcsStatus'),
    ecsUuid?: string(name='EcsUuid'),
    expireTime?: long(name='ExpireTime'),
    imageVersionName?: string(name='ImageVersionName'),
    instanceId?: string(name='InstanceId'),
    planCode?: string(name='PlanCode'),
    planName?: string(name='PlanName'),
    planUpgradeStatus?: int32(name='PlanUpgradeStatus'),
    planUpgradeable?: string(name='PlanUpgradeable'),
    productCode?: string(name='ProductCode'),
    productName?: string(name='ProductName'),
    publicAccessControl?: int32(name='PublicAccessControl'),
    regionName?: string(name='RegionName'),
    regionNo?: string(name='RegionNo'),
    renewable?: boolean(name='Renewable'),
    startTime?: long(name='StartTime'),
    status?: int32(name='Status'),
    upgradeStatus?: int32(name='UpgradeStatus'),
    vendorCode?: string(name='VendorCode'),
    vswitchId?: string(name='VswitchId'),
    zoneNo?: string(name='ZoneNo'),
  }(name='InstanceInfo'),
  requestId?: string(name='RequestId'),
}

model DescribeSyncInfoResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeSyncInfoResponseBody(name='body'),
}

async function describeSyncInfoWithOptions(request: DescribeSyncInfoRequest, runtime: Util.RuntimeOptions): DescribeSyncInfoResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeSyncInfo',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeSyncInfo(request: DescribeSyncInfoRequest): DescribeSyncInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeSyncInfoWithOptions(request, runtime);
}

model GetAgentListRequest {
  agentIp?: string(name='AgentIp'),
  agentOs?: string(name='AgentOs'),
  agentStatus?: int32(name='AgentStatus'),
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model GetAgentListResponseBody = {
  agentList?: [ 
    {
      agentId?: string(name='AgentId'),
      agentOs?: string(name='AgentOs'),
      agentPort?: string(name='AgentPort'),
      agentStatus?: int32(name='AgentStatus'),
      agentVersion?: string(name='AgentVersion'),
      ecsId?: string(name='EcsId'),
      firstLoginTime?: string(name='FirstLoginTime'),
      lastActiveTime?: string(name='LastActiveTime'),
      pktLoss?: int32(name='PktLoss'),
      privateIp?: string(name='PrivateIp'),
      publicIp?: string(name='PublicIp'),
      rmagentCpu?: int32(name='RmagentCpu'),
      rmagentMem?: int32(name='RmagentMem'),
      sendByteCount?: long(name='SendByteCount'),
      sendBytes?: long(name='SendBytes'),
      sendPacketCount?: long(name='SendPacketCount'),
      sendPackets?: long(name='SendPackets'),
      vpcId?: string(name='VpcId'),
    }
  ](name='AgentList'),
  requestId?: string(name='RequestId'),
}

model GetAgentListResponse = {
  headers: map[string]string(name='headers'),
  body: GetAgentListResponseBody(name='body'),
}

async function getAgentListWithOptions(request: GetAgentListRequest, runtime: Util.RuntimeOptions): GetAgentListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentIp)) {
    query['AgentIp'] = request.agentIp;
  }
  if (!Util.isUnset(request.agentOs)) {
    query['AgentOs'] = request.agentOs;
  }
  if (!Util.isUnset(request.agentStatus)) {
    query['AgentStatus'] = request.agentStatus;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetAgentList',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAgentList(request: GetAgentListRequest): GetAgentListResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAgentListWithOptions(request, runtime);
}

model GetLogDetailRequest {
  beginDate?: string(name='BeginDate'),
  endDate?: string(name='EndDate'),
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
  sqlId?: string(name='SqlId'),
}

model GetLogDetailResponseBody = {
  affectRows?: int32(name='AffectRows'),
  appClientIp?: string(name='AppClientIp'),
  appUsername?: string(name='AppUsername'),
  captureTime?: string(name='CaptureTime'),
  clientIp?: string(name='ClientIp'),
  clientMac?: string(name='ClientMac'),
  clientOsUser?: string(name='ClientOsUser'),
  clientPort?: int32(name='ClientPort'),
  clientProgram?: string(name='ClientProgram'),
  dbId?: int32(name='DbId'),
  dbServer?: string(name='DbServer'),
  dbUser?: string(name='DbUser'),
  execCostUS?: int32(name='ExecCostUS'),
  fetchCostUS?: int32(name='FetchCostUS'),
  instName?: string(name='InstName'),
  requestId?: string(name='RequestId'),
  responseCode?: string(name='ResponseCode'),
  responseText?: string(name='ResponseText'),
  riskLevel?: int32(name='RiskLevel'),
  ruleId?: int32(name='RuleId'),
  ruleKeyId?: int32(name='RuleKeyId'),
  ruleName?: string(name='RuleName'),
  ruleType?: int32(name='RuleType'),
  schema?: string(name='Schema'),
  serverMac?: string(name='ServerMac'),
  sessionId?: string(name='SessionId'),
  sessionLoginTime?: string(name='SessionLoginTime'),
  sessionLogoutTime?: string(name='SessionLogoutTime'),
  sqlContent?: string(name='SqlContent'),
  sqlId?: string(name='SqlId'),
  sqlResult?: string(name='SqlResult'),
  sqlType?: string(name='SqlType'),
  sqlTypeName?: string(name='SqlTypeName'),
  templateContent?: string(name='TemplateContent'),
  templateId?: string(name='TemplateId'),
  templateRules?: [ string ](name='TemplateRules'),
}

model GetLogDetailResponse = {
  headers: map[string]string(name='headers'),
  body: GetLogDetailResponseBody(name='body'),
}

async function getLogDetailWithOptions(request: GetLogDetailRequest, runtime: Util.RuntimeOptions): GetLogDetailResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.beginDate)) {
    query['BeginDate'] = request.beginDate;
  }
  if (!Util.isUnset(request.endDate)) {
    query['EndDate'] = request.endDate;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.sqlId)) {
    query['SqlId'] = request.sqlId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetLogDetail',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getLogDetail(request: GetLogDetailRequest): GetLogDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  return getLogDetailWithOptions(request, runtime);
}

model GetLogListRequest {
  beginDate?: string(name='BeginDate'),
  clientIpList?: [ string ](name='ClientIpList'),
  clientProgramList?: [ string ](name='ClientProgramList'),
  dbHostList?: [ string ](name='DbHostList'),
  dbId?: int32(name='DbId'),
  dbUserList?: [ string ](name='DbUserList'),
  endDate?: string(name='EndDate'),
  instanceId?: string(name='InstanceId'),
  isSuccess?: string(name='IsSuccess'),
  maxAffectRows?: int32(name='MaxAffectRows'),
  maxExecCostUS?: int32(name='MaxExecCostUS'),
  minAffectRows?: int32(name='MinAffectRows'),
  minExecCostUS?: int32(name='MinExecCostUS'),
  pageNumber?: int32(name='PageNumber'),
  pageSize?: int32(name='PageSize'),
  regionId?: string(name='RegionId'),
  riskLevelList?: [ string ](name='RiskLevelList'),
  ruleName?: string(name='RuleName'),
  ruleTypeList?: [ string ](name='RuleTypeList'),
  sessionId?: string(name='SessionId'),
  sqlId?: string(name='SqlId'),
  sqlKey?: string(name='SqlKey'),
  sqlTypeList?: [ string ](name='SqlTypeList'),
  templateId?: string(name='TemplateId'),
}

model GetLogListResponseBody = {
  beginDate?: string(name='BeginDate'),
  endDate?: string(name='EndDate'),
  incomplete?: string(name='Incomplete'),
  pageNumber?: int32(name='PageNumber'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  results?: [ 
    {
      affectRows?: int32(name='AffectRows'),
      appClientIp?: string(name='AppClientIp'),
      appUsername?: string(name='AppUsername'),
      captureTime?: string(name='CaptureTime'),
      clientIp?: string(name='ClientIp'),
      clientMac?: string(name='ClientMac'),
      clientOsUser?: string(name='ClientOsUser'),
      clientPort?: int32(name='ClientPort'),
      clientProgram?: string(name='ClientProgram'),
      dbId?: int32(name='DbId'),
      dbServer?: string(name='DbServer'),
      dbUser?: string(name='DbUser'),
      execCostUS?: int32(name='ExecCostUS'),
      fetchCostUS?: int32(name='FetchCostUS'),
      instName?: string(name='InstName'),
      responseCode?: string(name='ResponseCode'),
      responseText?: string(name='ResponseText'),
      riskLevel?: int32(name='RiskLevel'),
      ruleId?: int32(name='RuleId'),
      ruleKeyId?: int32(name='RuleKeyId'),
      ruleName?: string(name='RuleName'),
      ruleType?: int32(name='RuleType'),
      schema?: string(name='Schema'),
      serverMac?: string(name='ServerMac'),
      sessionId?: string(name='SessionId'),
      sessionLoginTime?: string(name='SessionLoginTime'),
      sessionLogoutTime?: string(name='SessionLogoutTime'),
      sqlContent?: string(name='SqlContent'),
      sqlId?: string(name='SqlId'),
      sqlType?: string(name='SqlType'),
      templateId?: string(name='TemplateId'),
    }
  ](name='Results'),
  totalCount?: int32(name='TotalCount'),
}

model GetLogListResponse = {
  headers: map[string]string(name='headers'),
  body: GetLogListResponseBody(name='body'),
}

async function getLogListWithOptions(request: GetLogListRequest, runtime: Util.RuntimeOptions): GetLogListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.beginDate)) {
    query['BeginDate'] = request.beginDate;
  }
  if (!Util.isUnset(request.clientIpList)) {
    query['ClientIpList'] = request.clientIpList;
  }
  if (!Util.isUnset(request.clientProgramList)) {
    query['ClientProgramList'] = request.clientProgramList;
  }
  if (!Util.isUnset(request.dbHostList)) {
    query['DbHostList'] = request.dbHostList;
  }
  if (!Util.isUnset(request.dbId)) {
    query['DbId'] = request.dbId;
  }
  if (!Util.isUnset(request.dbUserList)) {
    query['DbUserList'] = request.dbUserList;
  }
  if (!Util.isUnset(request.endDate)) {
    query['EndDate'] = request.endDate;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.isSuccess)) {
    query['IsSuccess'] = request.isSuccess;
  }
  if (!Util.isUnset(request.maxAffectRows)) {
    query['MaxAffectRows'] = request.maxAffectRows;
  }
  if (!Util.isUnset(request.maxExecCostUS)) {
    query['MaxExecCostUS'] = request.maxExecCostUS;
  }
  if (!Util.isUnset(request.minAffectRows)) {
    query['MinAffectRows'] = request.minAffectRows;
  }
  if (!Util.isUnset(request.minExecCostUS)) {
    query['MinExecCostUS'] = request.minExecCostUS;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.riskLevelList)) {
    query['RiskLevelList'] = request.riskLevelList;
  }
  if (!Util.isUnset(request.ruleName)) {
    query['RuleName'] = request.ruleName;
  }
  if (!Util.isUnset(request.ruleTypeList)) {
    query['RuleTypeList'] = request.ruleTypeList;
  }
  if (!Util.isUnset(request.sessionId)) {
    query['SessionId'] = request.sessionId;
  }
  if (!Util.isUnset(request.sqlId)) {
    query['SqlId'] = request.sqlId;
  }
  if (!Util.isUnset(request.sqlKey)) {
    query['SqlKey'] = request.sqlKey;
  }
  if (!Util.isUnset(request.sqlTypeList)) {
    query['SqlTypeList'] = request.sqlTypeList;
  }
  if (!Util.isUnset(request.templateId)) {
    query['TemplateId'] = request.templateId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetLogList',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getLogList(request: GetLogListRequest): GetLogListResponse {
  var runtime = new Util.RuntimeOptions{};
  return getLogListWithOptions(request, runtime);
}

model GetSessionListRequest {
  actionList?: [ string ](name='ActionList'),
  beginDate?: string(name='BeginDate'),
  clientIpList?: [ string ](name='ClientIpList'),
  clientProgramList?: [ string ](name='ClientProgramList'),
  dbHostList?: [ string ](name='DbHostList'),
  dbId?: int32(name='DbId'),
  dbUserList?: [ string ](name='DbUserList'),
  endDate?: string(name='EndDate'),
  instanceId?: string(name='InstanceId'),
  pageNumber?: int32(name='PageNumber'),
  pageSize?: int32(name='PageSize'),
  regionId?: string(name='RegionId'),
  sessionId?: string(name='SessionId'),
}

model GetSessionListResponseBody = {
  beginDate?: string(name='BeginDate'),
  endDate?: string(name='EndDate'),
  incomplete?: string(name='Incomplete'),
  pageNumber?: int32(name='PageNumber'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  results?: [ 
    {
      action?: string(name='Action'),
      captureTime?: string(name='CaptureTime'),
      clientIp?: string(name='ClientIp'),
      clientMac?: string(name='ClientMac'),
      clientOsUser?: string(name='ClientOsUser'),
      clientPort?: int32(name='ClientPort'),
      clientProgram?: string(name='ClientProgram'),
      dbId?: int32(name='DbId'),
      dbUser?: string(name='DbUser'),
      loginCode?: int32(name='LoginCode'),
      loginMessage?: string(name='LoginMessage'),
      serverIp?: string(name='ServerIp'),
      serverMac?: string(name='ServerMac'),
      serverPort?: int32(name='ServerPort'),
      sessionId?: string(name='SessionId'),
    }
  ](name='Results'),
  totalCount?: long(name='TotalCount'),
}

model GetSessionListResponse = {
  headers: map[string]string(name='headers'),
  body: GetSessionListResponseBody(name='body'),
}

async function getSessionListWithOptions(request: GetSessionListRequest, runtime: Util.RuntimeOptions): GetSessionListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.actionList)) {
    query['ActionList'] = request.actionList;
  }
  if (!Util.isUnset(request.beginDate)) {
    query['BeginDate'] = request.beginDate;
  }
  if (!Util.isUnset(request.clientIpList)) {
    query['ClientIpList'] = request.clientIpList;
  }
  if (!Util.isUnset(request.clientProgramList)) {
    query['ClientProgramList'] = request.clientProgramList;
  }
  if (!Util.isUnset(request.dbHostList)) {
    query['DbHostList'] = request.dbHostList;
  }
  if (!Util.isUnset(request.dbId)) {
    query['DbId'] = request.dbId;
  }
  if (!Util.isUnset(request.dbUserList)) {
    query['DbUserList'] = request.dbUserList;
  }
  if (!Util.isUnset(request.endDate)) {
    query['EndDate'] = request.endDate;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.sessionId)) {
    query['SessionId'] = request.sessionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetSessionList',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getSessionList(request: GetSessionListRequest): GetSessionListResponse {
  var runtime = new Util.RuntimeOptions{};
  return getSessionListWithOptions(request, runtime);
}

model ListDataSourceAttributeRequest {
  dbIds?: [ string ](name='DbIds'),
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model ListDataSourceAttributeResponseBody = {
  dbList?: [ 
    {
      auditMode?: string(name='AuditMode'),
      dbId?: int32(name='DbId'),
      resultAuditMaxLine?: int32(name='ResultAuditMaxLine'),
      resultAuditMaxSize?: int32(name='ResultAuditMaxSize'),
      resultAuditMode?: string(name='ResultAuditMode'),
    }
  ](name='DbList'),
  requestId?: string(name='RequestId'),
}

model ListDataSourceAttributeResponse = {
  headers: map[string]string(name='headers'),
  body: ListDataSourceAttributeResponseBody(name='body'),
}

async function listDataSourceAttributeWithOptions(request: ListDataSourceAttributeRequest, runtime: Util.RuntimeOptions): ListDataSourceAttributeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dbIds)) {
    query['DbIds'] = request.dbIds;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListDataSourceAttribute',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listDataSourceAttribute(request: ListDataSourceAttributeRequest): ListDataSourceAttributeResponse {
  var runtime = new Util.RuntimeOptions{};
  return listDataSourceAttributeWithOptions(request, runtime);
}

model ListDataSourcesRequest {
  dbId?: int32(name='DbId'),
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model ListDataSourcesResponseBody = {
  dbList?: [ 
    {
      assetType?: int32(name='AssetType'),
      auditSwitch?: int32(name='AuditSwitch'),
      createTime?: string(name='CreateTime'),
      dbAddresses?: [ string ](name='DbAddresses'),
      dbCertificate?: string(name='DbCertificate'),
      dbId?: int32(name='DbId'),
      dbInstanceId?: string(name='DbInstanceId'),
      dbName?: string(name='DbName'),
      dbType?: int32(name='DbType'),
      dbTypeName?: string(name='DbTypeName'),
      dbUsername?: string(name='DbUsername'),
      dbVersion?: int32(name='DbVersion'),
      dbVersionName?: string(name='DbVersionName'),
    }
  ](name='DbList'),
  requestId?: string(name='RequestId'),
}

model ListDataSourcesResponse = {
  headers: map[string]string(name='headers'),
  body: ListDataSourcesResponseBody(name='body'),
}

async function listDataSourcesWithOptions(request: ListDataSourcesRequest, runtime: Util.RuntimeOptions): ListDataSourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dbId)) {
    query['DbId'] = request.dbId;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListDataSources',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listDataSources(request: ListDataSourcesRequest): ListDataSourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listDataSourcesWithOptions(request, runtime);
}

model ListSystemAlarmsRequest {
  alarmType?: int32(name='AlarmType'),
  beginDate?: string(name='BeginDate'),
  endDate?: string(name='EndDate'),
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model ListSystemAlarmsResponseBody = {
  alarms?: [ 
    {
      alarmDetail?: string(name='AlarmDetail'),
      alarmId?: int32(name='AlarmId'),
      alarmType?: string(name='AlarmType'),
      createTime?: string(name='CreateTime'),
      readMark?: int32(name='ReadMark'),
    }
  ](name='Alarms'),
  requestId?: string(name='RequestId'),
}

model ListSystemAlarmsResponse = {
  headers: map[string]string(name='headers'),
  body: ListSystemAlarmsResponseBody(name='body'),
}

async function listSystemAlarmsWithOptions(request: ListSystemAlarmsRequest, runtime: Util.RuntimeOptions): ListSystemAlarmsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.alarmType)) {
    query['AlarmType'] = request.alarmType;
  }
  if (!Util.isUnset(request.beginDate)) {
    query['BeginDate'] = request.beginDate;
  }
  if (!Util.isUnset(request.endDate)) {
    query['EndDate'] = request.endDate;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListSystemAlarms',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listSystemAlarms(request: ListSystemAlarmsRequest): ListSystemAlarmsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSystemAlarmsWithOptions(request, runtime);
}

model ListTagKeysRequest {
  currentPage?: int32(name='CurrentPage'),
  pageSize?: int32(name='PageSize'),
  regionId?: string(name='RegionId'),
  resourceType?: string(name='ResourceType'),
}

model ListTagKeysResponseBody = {
  currentPage?: int32(name='CurrentPage'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  tagKeys?: [ 
    {
      tagCount?: int32(name='TagCount'),
      tagKey?: string(name='TagKey'),
    }
  ](name='TagKeys'),
  totalCount?: int32(name='TotalCount'),
}

model ListTagKeysResponse = {
  headers: map[string]string(name='headers'),
  body: ListTagKeysResponseBody(name='body'),
}

async function listTagKeysWithOptions(request: ListTagKeysRequest, runtime: Util.RuntimeOptions): ListTagKeysResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTagKeys',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listTagKeys(request: ListTagKeysRequest): ListTagKeysResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTagKeysWithOptions(request, runtime);
}

model ListTagResourcesRequest {
  nextToken?: string(name='NextToken'),
  regionId?: string(name='RegionId'),
  resourceId?: [ string ](name='ResourceId'),
  resourceType?: string(name='ResourceType'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model ListTagResourcesResponseBody = {
  nextToken?: string(name='NextToken'),
  requestId?: string(name='RequestId'),
  tagResources?: [ 
    {
      resourceId?: string(name='ResourceId'),
      resourceType?: string(name='ResourceType'),
      tagKey?: string(name='TagKey'),
      tagValue?: string(name='TagValue'),
    }
  ](name='TagResources'),
}

model ListTagResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: ListTagResourcesResponseBody(name='body'),
}

async function listTagResourcesWithOptions(request: ListTagResourcesRequest, runtime: Util.RuntimeOptions): ListTagResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTagResources',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listTagResources(request: ListTagResourcesRequest): ListTagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTagResourcesWithOptions(request, runtime);
}

model ModifyCustomNameRequest {
  commodityCode?: string(name='CommodityCode'),
  customName?: string(name='CustomName'),
  instanceId?: string(name='InstanceId'),
  sourceIp?: string(name='SourceIp'),
}

model ModifyCustomNameResponseBody = {
  requestId?: string(name='RequestId'),
}

model ModifyCustomNameResponse = {
  headers: map[string]string(name='headers'),
  body: ModifyCustomNameResponseBody(name='body'),
}

async function modifyCustomNameWithOptions(request: ModifyCustomNameRequest, runtime: Util.RuntimeOptions): ModifyCustomNameResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.commodityCode)) {
    query['CommodityCode'] = request.commodityCode;
  }
  if (!Util.isUnset(request.customName)) {
    query['CustomName'] = request.customName;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.sourceIp)) {
    query['SourceIp'] = request.sourceIp;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyCustomName',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function modifyCustomName(request: ModifyCustomNameRequest): ModifyCustomNameResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyCustomNameWithOptions(request, runtime);
}

model ModifyInstanceAttributeRequest {
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model ModifyInstanceAttributeResponseBody = {
  requestId?: string(name='RequestId'),
}

model ModifyInstanceAttributeResponse = {
  headers: map[string]string(name='headers'),
  body: ModifyInstanceAttributeResponseBody(name='body'),
}

async function modifyInstanceAttributeWithOptions(request: ModifyInstanceAttributeRequest, runtime: Util.RuntimeOptions): ModifyInstanceAttributeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.description)) {
    query['Description'] = request.description;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyInstanceAttribute',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function modifyInstanceAttribute(request: ModifyInstanceAttributeRequest): ModifyInstanceAttributeResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyInstanceAttributeWithOptions(request, runtime);
}

model ModifyPlanRequest {
  commodityCode?: string(name='CommodityCode'),
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model ModifyPlanResponseBody = {
  requestId?: string(name='RequestId'),
}

model ModifyPlanResponse = {
  headers: map[string]string(name='headers'),
  body: ModifyPlanResponseBody(name='body'),
}

async function modifyPlanWithOptions(request: ModifyPlanRequest, runtime: Util.RuntimeOptions): ModifyPlanResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.commodityCode)) {
    query['CommodityCode'] = request.commodityCode;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyPlan',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function modifyPlan(request: ModifyPlanRequest): ModifyPlanResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyPlanWithOptions(request, runtime);
}

model MoveResourceGroupRequest {
  regionId?: string(name='RegionId'),
  resourceGroupId?: string(name='ResourceGroupId'),
  resourceId?: string(name='ResourceId'),
  resourceType?: string(name='ResourceType'),
}

model MoveResourceGroupResponseBody = {
  requestId?: string(name='RequestId'),
}

model MoveResourceGroupResponse = {
  headers: map[string]string(name='headers'),
  body: MoveResourceGroupResponseBody(name='body'),
}

async function moveResourceGroupWithOptions(request: MoveResourceGroupRequest, runtime: Util.RuntimeOptions): MoveResourceGroupResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceGroupId)) {
    query['ResourceGroupId'] = request.resourceGroupId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'MoveResourceGroup',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function moveResourceGroup(request: MoveResourceGroupRequest): MoveResourceGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  return moveResourceGroupWithOptions(request, runtime);
}

model RefundInstanceRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
  serviceCode?: string(name='ServiceCode'),
}

model RefundInstanceResponseBody = {
  requestId?: string(name='RequestId'),
}

model RefundInstanceResponse = {
  headers: map[string]string(name='headers'),
  body: RefundInstanceResponseBody(name='body'),
}

async function refundInstanceWithOptions(request: RefundInstanceRequest, runtime: Util.RuntimeOptions): RefundInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.serviceCode)) {
    query['ServiceCode'] = request.serviceCode;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'RefundInstance',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function refundInstance(request: RefundInstanceRequest): RefundInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return refundInstanceWithOptions(request, runtime);
}

model StartInstanceRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
  vswitchId?: string(name='VswitchId'),
}

model StartInstanceResponseBody = {
  requestId?: string(name='RequestId'),
}

model StartInstanceResponse = {
  headers: map[string]string(name='headers'),
  body: StartInstanceResponseBody(name='body'),
}

async function startInstanceWithOptions(request: StartInstanceRequest, runtime: Util.RuntimeOptions): StartInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.vswitchId)) {
    query['VswitchId'] = request.vswitchId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'StartInstance',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function startInstance(request: StartInstanceRequest): StartInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return startInstanceWithOptions(request, runtime);
}

model TagResourcesRequest {
  regionId?: string(name='RegionId'),
  resourceId?: [ string ](name='ResourceId'),
  resourceType?: string(name='ResourceType'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model TagResourcesResponseBody = {
  requestId?: string(name='RequestId'),
}

model TagResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: TagResourcesResponseBody(name='body'),
}

async function tagResourcesWithOptions(request: TagResourcesRequest, runtime: Util.RuntimeOptions): TagResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.tag)) {
    query['Tag'] = request.tag;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TagResources',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function tagResources(request: TagResourcesRequest): TagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return tagResourcesWithOptions(request, runtime);
}

model UntagResourcesRequest {
  all?: boolean(name='All'),
  regionId?: string(name='RegionId'),
  resourceId?: [ string ](name='ResourceId'),
  resourceType?: string(name='ResourceType'),
  tagKey?: [ string ](name='TagKey'),
}

model UntagResourcesResponseBody = {
  requestId?: string(name='RequestId'),
}

model UntagResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: UntagResourcesResponseBody(name='body'),
}

async function untagResourcesWithOptions(request: UntagResourcesRequest, runtime: Util.RuntimeOptions): UntagResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.all)) {
    query['All'] = request.all;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.tagKey)) {
    query['TagKey'] = request.tagKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UntagResources',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function untagResources(request: UntagResourcesRequest): UntagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return untagResourcesWithOptions(request, runtime);
}

model UpgradeInstanceVersionRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model UpgradeInstanceVersionResponseBody = {
  requestId?: string(name='RequestId'),
}

model UpgradeInstanceVersionResponse = {
  headers: map[string]string(name='headers'),
  body: UpgradeInstanceVersionResponseBody(name='body'),
}

async function upgradeInstanceVersionWithOptions(request: UpgradeInstanceVersionRequest, runtime: Util.RuntimeOptions): UpgradeInstanceVersionResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpgradeInstanceVersion',
    version = '2018-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function upgradeInstanceVersion(request: UpgradeInstanceVersionRequest): UpgradeInstanceVersionResponse {
  var runtime = new Util.RuntimeOptions{};
  return upgradeInstanceVersionWithOptions(request, runtime);
}

